package Model;

import Impl.FlyBehaviorImpl;
import Impl.ShootBehavior;
import Impl.Target;

/**
 * 增加state属性
 * 引入shoot策略关系
 */
public class Plane implements Target {
    private FlyBehaviorImpl flyBehavior;
    private ShootBehavior shootBehavior;
    private boolean state;   //0:被击落    1:存活

    public void setFlyBehavior(FlyBehaviorImpl flyBehavior) {
        this.flyBehavior = flyBehavior;
    }

    public void setShootBehavior(ShootBehavior shootBehavior){
        this.shootBehavior = shootBehavior;
    }

    public boolean getState() {
        if(!state){
            System.out.println("我被击落了");
        }
        else System.out.println("我未被击落");
        return state;
    }

    public void setState(boolean state) {
        this.state = state;
    }

    public void display(){
        System.out.println("i am a plane");
    }

    public void performFly(){
        flyBehavior.fly();
    }

    public void performShoot(Plane plane){
        shootBehavior.shoot(plane);
    }
}
